#ifndef __IAP_H__
#define __IAP_H__

#include "hc32l136k8ta.h"
#include "flash.h"

#define  RESET_PWR_ON       0xff
#define  RESET_RSTB         0x80
#define  RESET_SOFT         0x40   

typedef  void (*iapfun)(void);				//定义一个函数类型参数

#define  DI()      { __disable_irq();  }
#define  EI()      { __enable_irq();   }

#define  MCU_SoftRest()      { NVIC_SystemReset(); }  

void iap_load_app(uint32_t appxaddr);

#if 0

#define  FLASH_IAP_OPREAT_FLAG   0x66778899 

#define  flash_IAP_startaddr  0xfa00/*the last 3 sector of 127(512bytes)*/

//#define FLASH_BOOT_SIZE    0x4000    // 16k 

#define FLASH_APP_SIZE    0xa800    // = 42k 

#define FLASH_APP_ADDR	   0x00004000  /*应用程序起始地址*/

void iap_load_app(uint32_t appxaddr);	//执行flash里的app程序

en_result_t  IAP_write_a_sertor(uint32_t startaddr,uint8_t *appbuf);

void IAP_start_check(void);



//extern unsigned char const acbt_timer[0x800];

/* nb 组包eventdata数据结构*/
typedef struct
{   
	char packbuff[1024];
	uint8_t  packbuffhex[512];
}ota_t;

extern ota_t OTA;

#endif

#endif







































